require(["config"],function(config){
		require(["jquery","sw","swe","t","tb","ajax"],function(jquery,sw,swe,t,tb,ajax){

	/*-------------------------------轮播图------------------------------------------------------*/
		var mySwiper = new Swiper ('#big', {
//		        direction: 'vertical',
		        autoplay:2000,
			    loop: true,
			                                
			   // 分页器
			  pagination: '.swiper-pagination',
			  paginationClickable: true,
			  paginationBulletRender: function (swiper, index, className) {
			      return '<span class="' + className + '">' + (index + 1) + '</span>';
			  }
 			}) 
 	/*------------------------------倒计时------------------------------------------------------*/
// 		setInterval(function(){
//		var now = new Date();
//		var h = now.getHours();
//		var m = now.getMinutes();
//		var s = now.getSeconds();
//		
//		var _date = [
//			h<10?0:Math.floor(h/10), h%10,
//			m<10?0:Math.floor(m/10), m%10,
//			s<10?0:Math.floor(s/10), s%10
//			]
//		console.log(_date);
//		
//		var imgs = document.getElementsByTagName("img");
//		for(var i=0; i<imgs.length; i++){
//			imgs[i].src = "img/"+_date[i]+".png";
//		}
//	}, 1000);
 			
 			
 	/*-------------------------------二级菜单---------------------------------------------------*/				
   			$(".span1").mouseenter(function(){
   					$(".add1").show().mouseleave(function(){
   						$(".add1").hide();
   					});
   			});
   				
   			
   			$(".span2").mouseenter(function(){
   					$(".add1").hide();
   					$(".add2").show().mouseleave(function(){
   						$(".add2").hide();
   					
   				});
   			});	
   			
   			
			$(".span3").mouseenter(function(){		
						$(".add2").hide();
						$(".add3").show().mouseleave(function(){
   						$(".add3").hide();
   				});
			});
			
			
	 			$(".span4").mouseenter(function(){
	 				    $(".add3").hide();
	 					$(".add4").show().mouseleave(function(){
   						$(".add4").hide();
	 				});
	 			});	
	 			
	 			
	 			
	 		$(".span5").mouseenter(function(){
	 					$(".add4").hide();
	 					$(".add5").show().mouseleave(function(){
	 						$(".add5").hide();
	 					});
	 		});
	 		
	 		
	 		$(".span6").mouseenter(function(){
	 					$(".add5").hide();
	 					$(".add6").show().mouseleave(function(){
	 						$(".add6").hide();
	 			});
	 		});
	 					
	 		$(".span7").mouseenter(function(){
	 					$(".add6").hide();
	 					$(".add7").show().mouseleave(function(){
	 						$(".add7").hide();;
	 			});
	 		});
				
		
 	/*-----------------------------banner-mask--------------------------------------------------------*/		
 		var mask=$("<div></div>");
 		$("#add2").append(mask);
 		mask.addClass("addmask");
 		var mask1=$("<div></div>");
 		$("#add2").append(mask1);
 		mask1.addClass("addmask1");
 		var mask2=$("<div></div>");
 		$("#add2").append(mask2);
 		mask2.addClass("addmask2");
 		$(".add2-t").mouseover(function(){
 			$(".addmask").hide().siblings().show();
 			});	
 		$(".add2-c").mouseover(function(){	
 			$(".addmask1").hide().siblings().show();
 			})	;
 		$(".add2-b").mouseover(function(){			
 			$(".addmask2").hide().siblings().show();	
 		})
 		
 	
 	
 		
 		
 		/*--------------------------------底部轮播----------------------------------------------------*/
		 var mySwiper = new Swiper ('#small', {
			    //direction: 'vertical',
			    loop: true,
				autoplay:2000,
			    
		    // 如果需要前进后退按钮
		    nextButton: '.swiper-button-next',
		    prevButton: '.swiper-button-prev'
		    
		
		  });        
  
   		
  /*-----------------------------------获取商品信息----------------------------------------------*/
   		ajax.get("1.json",function(str){
   			var obj=JSON.parse(str);
   			var arr=obj.list;
   			//console.log(obj);
   			for (var i in arr) {
   				var lis=$("<li><a href='xq.html?id="+arr[i].id+"'><img src='../img/"+arr[i].img+"'></a><div class='gouwuche'>加入购物车</div></li>");
   				$(".shop-t").append(lis);
   			};
   			var col=obj.timer;
   			
   			for( var x in col ) {
   				var li1=$("<li><a href='xq.html?id="+col[x].id+"'><img src='../img/"+col[x].img+"'></a><div class='title'>"+col[x].title+"</div><div class='price1'>"+col[x].price+"</div><div class='price2'>"+col[x].oldprice+"</div><div class='space'></div><div class='timer-b'><a href='#'>"+col[x].btn+"</a></div>");
   			$(".ww").append(li1);
   			}
   			var newarr=obj.fruit;
   			//console.log(newarr);
   			for( var j in newarr){
   				var li2=$('<li><div class="fruitt"><div class="add-cart"></div><a href="xq.html?id='+newarr[j].id+'"><img src="../img/'+newarr[j].img+'" alt="" /></a></div><div class="fruitc"><a href="#">'+newarr[j].title+'</a></div><div class="fruitb"><b>'+newarr[j].price+'</b></div></li>');
   				$(".ccc").append(li2);
   			}
   			//2
   			var newarr2=obj.fruit2;
   			//console.log(newarr);
   			for( var j in newarr2){
   				var lia=$('<li><div class="fruitt"><div class="add-cart"></div><a href="xq.html?id='+newarr2[j].id+'"><img src="../img/'+newarr2[j].img+'" alt="" /></a></div><div class="fruitc"><a href="#">'+newarr2[j].title+'</a></div><div class="fruitb"><b>'+newarr2[j].price+'</b></div></li>');
   				$(".ddd").append(lia);
   			}
   			//3
   			var newarr3=obj.fruit3;
   			//console.log(newarr);
   			for( var j in newarr3){
   				var li3=$('<li><div class="fruitt"><div class="add-cart"></div><a href="xq.html?id='+newarr3[j].id+'"><img src="../img/'+newarr3[j].img+'" alt="" /></a></div><div class="fruitc"><a href="#">'+newarr3[j].title+'</a></div><div class="fruitb"><b>'+newarr3[j].price+'</b></div></li>');
   				$(".eee").append(li3);
   			}
   			//4
   			var newarr4=obj.fruit4;
   			//console.log(newarr);
   			for( var j in newarr4){
   				var li4=$('<li><div class="fruitt"><div class="add-cart"></div><a href="xq.html?id='+newarr4[j].id+'"><img src="../img/'+newarr4[j].img+'" alt="" /></a></div><div class="fruitc"><a href="#">'+newarr4[j].title+'</a></div><div class="fruitb"><b>'+newarr4[j].price+'</b></div></li>');
   				$(".fff").append(li4);
   			}
   			//5
   			var newarr5=obj.fruit5;
   			//console.log(newarr);
   			for( var j in newarr5){
   				var li5=$('<li><div class="fruitt"><div class="add-cart"></div><a href="xq.html?id='+newarr5[j].id+'"><img src="../img/'+newarr5[j].img+'" alt="" /></a></div><div class="fruitc"><a href="#">'+newarr5[j].title+'</a></div><div class="fruitb"><b>'+newarr5[j].price+'</b></div></li>');
   				$(".ggg").append(li5);
   			}
   			//
   			var newarr6=obj.fruit6;
   			//console.log(newarr);
   			for( var j in newarr6){
   				var li6=$('<li><div class="fruitt"><div class="add-cart"></div><a href="xq.html?id='+newarr6[j].id+'"><img src="../img/'+newarr6[j].img+'" alt="" /></a></div><div class="fruitc"><a href="#">'+newarr6[j].title+'</a></div><div class="fruitb"><b>'+newarr6[j].price+'</b></div></li>');
   				$(".iii").append(li6);
   			}
   	});
   	
   	/*---------------------------------add-cart-------------------------------------------------*/
window.onload = function(){
 		var addcart = $(".add-cart");
   		addcart.html("加入购物车");
   		$(".fruitt").mouseover(function(){
   			addcart.css("display","block");
	 		 $(this).append(addcart);
	 		 addcart.slideToggle("slow").stop();
   		}).mouseout(function(){
   			addcart	.slideToggle("slow").stop();
   			$(this).remove(addcart);
   		});
}
 /*------------------------------------文字轮播---------------------------------------------------------*/
		var mySwiper = new Swiper ('.wenzi', {
		    direction: 'vertical',
		     autoplay:3000,                                                                                                                                          
		    loop: true,
		
		});

/*------------------------------------------登录cookie--------------------------------------------------*/
		var aa = document.getElementById("sp");
		var bb = document.getElementById("tc");
		//登录之后
		var cc = document.getElementById("xx");
		//登录之前
		var dd = document.getElementById("login");
		if(getCookie("username") != "") {
		aa.innerHTML = (getCookie("suername")) ;
		//点击退出
		
		//登陆之前
		cc.style.display = "block";
		dd.style.display = "none";
	}else {
		cc.style.display = "none";
	}
	bb.onclick = function() {
		setCookie("username", '', -30);
        setCookie("password", '', -30);
		aa.innerHTML = "";
		dd.style.display = "block";
		cc.style.display = "none";
	}
		
		
		
		


 	});
 });				
 			
 			
  
 			
 			
 			
 			
 			
 			
 			
 			
 			
 			
 	
